<template>
  <div>
    <router-link to="/book/addSecondhand"><el-button>添加</el-button></router-link>
    <el-table
      :data="SecondhandList"
      :stripe="true"
      style="width: 100%">
      <el-table-column
        prop="id"
        label="编号">
      </el-table-column>
      <el-table-column
        prop="bookName"
        label="书名">
      </el-table-column>
      <el-table-column
        prop="bookPrice"
        label="原价">
      </el-table-column>
      <el-table-column
        prop="author"
        label="作者">
      </el-table-column>
      <el-table-column
        prop="description"
        label="描述">
      </el-table-column>
      <el-table-column
        prop="dangprice"
        label="估价">
      </el-table-column>
      <el-table-column
        label="操作">
        <template slot-scope="scope">
          <router-link :to="'/book/Volume?sid='+scope.row.id" v-if="role==1"><el-button>查看图书</el-button></router-link>
          <router-link :to="'/book/Volume?sid='+scope.row.id" v-if="role==2"><el-button>估价</el-button></router-link>
        </template>
      </el-table-column>
    </el-table>
    <router-view/>
  </div>
</template>

<script>
    export default {
        name: "SecondhandList",
      data(){
          return {
            SecondhandList:[],
            role:sessionStorage.getItem("role")
          }
      },
      created(){
        //发出ajax请求请求后端代码
        this.axios.get("/secondhandBook/selectAll").then((resp)=>{
          this.SecondhandList=resp.data;
        });
      }
    }
</script>

<style scoped>

</style>
